﻿using System;
using System.Collections.Generic;
using System.Text;

/**
*@file       EnterWorldEvent.cs
*@brief      event after object enter the world
*
*@author     graywind
*@version    1.0.0.1
*@data       2012/03/04
*/

partial class GameWorld : GameWorldInitializer
{
    #region override this function
    /// <summary>
    /// initialize
    /// </summary>
    protected new void DoInit()
    {
        PlayerEnterEvent += WorldEvent.OnPlayerEnter;
        PlayerLeaveEvent += WorldEvent.OnPlayerLeave;
        PlayerWorldChangeEvent += WorldEvent.OnPlayerWorldChange;
    }
    #endregion
}

public class WorldEvent
{
    #region callback
    /// <summary>
    /// call this function after player enter the world
    /// </summary>
    /// <param name="obj"></param>
    public static void OnPlayerEnter(WorldObject.PlayerObject obj)
    {
		int server_session = gwBedrockApp.GameServer.GetInstance.GetPosHandle(obj.ObjectInfo.WorldId);
		if(server_session != NetLib.INVALID_SESSION)
		{
			msgPSRole_EnterWorld role_enter_world = new msgPSRole_EnterWorld(server_session, obj.ObjectInfo, obj.PlayerDetail);
		}
    }

    /// <summary>
    /// call this function after player leave the world
    /// </summary>
    /// <param name="obj"></param>
    public static void OnPlayerLeave(WorldObject.PlayerObject obj)
    {

    }

    /// <summary>
    /// call this function after player chang the world
    /// </summary>
    /// <param name="obj"></param>
    /// <param name="world_id"></param>
    public static void OnPlayerWorldChange(WorldObject.PlayerObject obj, int world_id)
    {

    }
    #endregion
}